import { defineStore } from 'pinia'
import { getHotSuggests, getHomeCategories,getHouseList } from '@/services'
export const useHomeStore = defineStore('home', {
  state: () => ({
    hotSuggestsArr: [],
    categories: [],
    houseList: [],
    curPage:1
  }),
  getters: {
  },
  actions: {
    async fetchHotSuggests() {
      const res = await getHotSuggests()
      this.hotSuggestsArr = res.data
    },

    async fetchHomeCategories() {
      const res = await getHomeCategories()
      this.categories = res.data
    },

    async fetchHouseList() {
      const res = await getHouseList(this.curPage++)
      // 追加数据
      this.houseList.push(...res.data)
    },
  }
})
